/**
 * View package.
 */
package fr.umlv.m2.ig.view;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import javax.swing.JComponent;

/**
 * This class defines the component used to display the subway map from an image.
 * 
 * @author Gambouele Bertrand.
 * @author Viravout Alexandre.
 */
@SuppressWarnings("serial")
public class ImagePanel extends JComponent {

	/**
	 * The image which will be drawn in the component.
	 */
	private BufferedImage image;
	
	/**
	 * Creates a new {@code ImagePanel} object.
	 */
	public ImagePanel() {}

	/**
	 * Sets a new image to the component.
	 * 
	 * @param image the image to set.
	 */
	public void setImage(final BufferedImage image) {
		this.image = image;
	}

	@Override
	protected void paintComponent(final Graphics g) {
		Graphics2D g2 = (Graphics2D)g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.drawImage(image, null, null);
	}
}
